package concurrence;

/**
 * Created by gzhd on 2017/11/20.
 */
public final class ImmutableDemo {
    public final int[] myArray;
    public ImmutableDemo(int[] array) {
        this.myArray = array.clone(); // wrong

    }


    public static void main(String[] args) {
        int [] abc=new  int [3];
        abc[0]=1;
        abc[1]=2;
        abc[2]=3;
        ImmutableDemo immutableDemo = new ImmutableDemo(abc);
        abc[0]=10;
        System.out.println(immutableDemo.myArray[0]);
        System.out.println(immutableDemo.myArray[1]);
        System.out.println(immutableDemo.myArray[2]);


    }
}
